#include <iostream>
using std::cout;
using std::endl;

#include "BinaryTree.h"

int main()
{
	//初始化一颗二叉搜索树，根节点赋值为9
	BinaryTree<int>* brtree=new BinaryTree<int>(9);
	//向二叉搜索树中插入节点
	brtree->treeInsert(4);
	brtree->treeInsert(2);
	brtree->treeInsert(6);
	brtree->treeInsert(7);
	brtree->treeInsert(5);
	brtree->treeInsert(13);
	brtree->treeInsert(10);
	brtree->treeInsert(11);
	brtree->treeInsert(14);

	cout<<"先序遍历：";
	brtree->preorder();
	cout<<"\n中序遍历：";
	brtree->inorder();
	cout<<"\n后序遍历：";
	brtree->postorder();
	cout<<endl;

	//获取树高
	cout<<"树高："<<brtree->getHeight()<<endl;

	//获取叶子数
	cout<<"叶子数："<<brtree->getLeafNum()<<endl;

	//复制二叉树
	cout<<"复制二叉树!"<<endl;
	BinaryTree<int>* brtree2 = brtree->clone();
	cout<<"复制的二叉树先序遍历：";
	brtree2->preorder();
	cout<<endl;
	//交换每个节点的左右子树
	cout<<"交换每个节点的左右子树！"<<endl;
	brtree->swapChil();
	cout<<"交换后的先序遍历：";
	brtree->preorder();
	cout<<endl;
	//层序遍历
	cout<<"层序遍历："<<endl;
	brtree->printNodeByLevel();
	//调用析构函数删除整棵树
	cout<<"删除整个二叉树："<<endl;
	delete brtree;
	return 0;

//Testing for git
	
}
